#pragma once

#include <windows.h>
#include <string>

class GDICapture {
public:
    GDICapture();
    ~GDICapture();

    bool Initialize();
    void Cleanup();
    bool CaptureScreen(HBITMAP& hBitmap, int& width, int& height);
    bool IsInitialized() const { return m_initialized; }
    std::string GetLastError() const { return m_lastError; }

private:
    bool SetupDCsForDesktop(HDESK hDesktop);
    void CleanupDCs();
    bool CaptureWithAlternativeMethod(HBITMAP& hBitmap, int& width, int& height);

private:
    bool m_initialized;
    std::string m_lastError;

    HDC m_screenDC;
    HDC m_memoryDC;
    HDESK m_currentDesktop;
    int m_screenWidth;
    int m_screenHeight;
};